#pragma once

#include "Widgets/WidgetAttribute.h"
#include "Math/Color.h"
#include "WidgetAnimation.m.h"

class RWidgetAnimationTrigger;

// Create a new animated float attribute
// usage:
//    //let Widget's X attribute animated from 0 to 100 in 1.0 seconds 
//    Widget.X=AnimatedAttributeCreator.CreateFloatAttribute(0.f, 100.f, 1.0f)
RSTRUCT(ExtraHeader="Widgets/WidgetAnimationTrigger.h")
struct WHENGINE_API SAnimatedAttributeCreator
{
    ROBJECT

    // Create a new animated float attribute
    // the attribute will be animated from InitialValue to TargetValue in Duration
    // animation is automatically started when the attribute is first be used
    // @param InitialValue - The initial value of the attribute
    // @param TargetValue - The target value of the attribute
    // @param Duration - The duration of the animation,in seconds
    // @return The created attribute
    RFUNCTION()
    static TWidgetAttribute<float> CreateFloatAttribute(
        TWidgetAttribute<float> InitialValue,
        TWidgetAttribute<float> TargetValue,
        TWidgetAttribute<float> Duration
    ); 

    //create a bink color attribute, the color will blink between NormalColor and AnotherColor
    //usage:
    //    //let Widget's Color attribute blink between Red and Blue 
    //    //and the color will stay in Red or Blue for 0.5 seconds
    //    //before Condition is actived, the color is Red
    //    //after Condition is actived, the color will blink between Red and Blue
    //    //result is Blue(0.5s)->Red(0.5s)->Blue(0.5s)->Red(0.5s)-> ...
    //    //when Condition is deactivated, the blink will be stopped and the color will be Red again
    //    auto Trigger= NewObject<RWidgetAnimationTrigger>();
    //    Trigger->Duration=1.5f;
    //    Widget.Color=AnimatedAttributeCreator.CreateColorBlinkAttribute(Trigger,SColor::Red, SColor::Blue, 0.5f)
    //    Trigger->Activate();
    // @param Condition - if condition is actived, the blink will be started , if not, the blink will be stopped
    // @param NormalColor - The initial color before the blink
    // @param AnotherColor - another color in the blink
    // @param OneColorDuration - The duration of the one color before changed, in seconds
    RFUNCTION()
    static TWidgetAttribute<SColor> CreateColorBlinkAttribute(
        TSharedObjectPtr<RWidgetAnimationTrigger> Condition,
        TWidgetAttribute<SColor> NormalColor,
        TWidgetAttribute<SColor> AnotherColor,
        TWidgetAttribute<float> OneColorDuration
    );

};
